
#include <mockcpp/mockcpp.hpp>
#include <testngpp/testngpp.hpp>

#include <Length.h>
#include <Volume.h>

USING_MOCKCPP_NS
USING_TESTNGPP_NS

FIXTURE(Measurement)
{
	TEST(should be able to compare: 1 oz == 3 tsp)
	{
		ASSERT_TRUE(Volume(1, OZ) == Volume(3, TSP));
	}

	TEST(should be able to compare: 1 tsp == 4 tbsp)
	{
		ASSERT_TRUE(Volume(1, TSP) == Volume(4, TBSP));
	}

	TEST(should be able to compare: 1 oz + 3 tsp == 2 oz)
	{
		ASSERT_TRUE(Volume(1, OZ) + Volume(3, TSP) == Volume(2, OZ));
	}

	TEST(should be able to compare: 1 tsp + 3 tbsp == 7 tbsp)
	{
		ASSERT_TRUE(Volume(1, TSP) + Volume(3, TBSP) == Volume(7, TBSP));
	}

	TEST(should be able to compare: 1 tbsp != 1 feet)
	{
        ASSERT_THROWS((Volume(1, TBSP) != Length(1, FEET)), int);
	}

	TEST(should not add different unit type together)
	{
        ASSERT_THROWS((Volume(1, TBSP) + Length(1, FEET)), int);
	}

	TEST(should not allow user to define a new unit)
	{
        UnitType    unitType;
        ASSERT_THROWS((Unit(10, unitType)), int);
	}
    TEST("19 TSP format to string is: 3 OZ 1 TSP")
    {
        Volume  volume(19, TSP);
        ASSERT_EQ(string("6 OZ 1 TSP"), volume.formatToString());
    }
    TEST("0 TSP format to string is: 0 TBSP")
    {
        Volume  volume(0, TSP);
        ASSERT_EQ(string("0 TBSP"), volume.formatToString());
    }
    TEST("3*4+1 TBSP format to string is: 1 OZ 1 TBSP")
    {
        Volume  volume(13, TBSP);
        ASSERT_EQ(string("1 OZ 1 TBSP"), volume.formatToString());
    }
    TEST("3 TSP format to string in base unit is: 12 TBSP")
    {
        Volume  volume(3, TSP);
        ASSERT_EQ(string("12 TBSP"), volume.formatToStringInBaseUnit());
    }
};


